package wsh;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.net.Socket;

public class send extends Socket {

	private static final String SERVER_IP = "127.0.0.1";
	// private static final String SERVER_IP = "服务器IP";
	private static final int SERVER_PORT = 8899;

	private Socket client;

	public send() throws Exception {
		super(SERVER_IP, SERVER_PORT);
		this.client = this;
	}

	public void sendFile(String ff) throws Exception {

		DataInputStream in = new DataInputStream(client.getInputStream());
		DataOutputStream out = new DataOutputStream(client.getOutputStream());
		out.writeUTF(ff);
		String z = in.readUTF();
		System.out.println(z);

	}

	/**
	 * 入口
	 * 
	 * @param args
	 */
	public void good(String ff) {
		try {
			send client = new send(); // 启动客户端连接
			client.sendFile(ff); // 传输文件
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}